package com.example.yunpicture.exception;

//异常处理工具类
public class ThrowUtils {
    public static void throwif(boolean condition, RuntimeException runtimeException) {
        if (condition){
            throw runtimeException;
        }
    }

    /**
     *
     * @param condition  条件
     * @param errorCode  错误码
     */
    public static void throwif(boolean condition, ErrorCode errorCode) {
        throwif(condition,new BusinessException(errorCode));
    }

    /**
     *
     * @param condition 条件
     * @param errorCode 错误码
     * @param message 错误信息
     */
    public static void throwif(boolean condition, ErrorCode errorCode, String message) {
        throwif(condition,new BusinessException(errorCode,message));
    }
}
